//
//  LGPatientWeightTipView.m
//  HeartDiseaseManage
//
//  Created by 1234 on 2023/3/6.
//

#import "LGPatientWeightTipView.h"

@interface LGPatientWeightTipView()
/**   */
@property (nonatomic , strong)UILabel *dateLabel;
/**   */
@property (nonatomic , strong)UILabel *weightLabel;
/**   */
@property (nonatomic , strong)UILabel *weightUnit;
/**   */
@property (nonatomic , strong)UILabel *waistlineLabel;
/**   */
@property (nonatomic , strong)UILabel *waistlineUnit;

@end

@implementation LGPatientWeightTipView

- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        self.cornerLayer.frame = self.bounds;
        self.backgroundColor = [UIColor colorWithString:@"#000000" alpha:0.7];
        [self addSubview:self.dateLabel];
        [self addSubview:self.weightLabel];
        [self addSubview:self.weightUnit];
        [self addSubview:self.waistlineLabel];
        [self addSubview:self.waistlineUnit];
        [self.dateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self).offset(viewPix(10));
            make.left.equalTo(self).offset(viewPix(12));
        }];
        [self.weightLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.dateLabel.mas_bottom).offset(viewPix(8));
            make.left.equalTo(self.dateLabel);
        }];
        [self.weightUnit mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.weightLabel.mas_right).offset(viewPix(5));
            make.centerY.equalTo(self.weightLabel);
        }];
        
        [self.waistlineLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.weightUnit.mas_right).offset(viewPix(16));
            make.centerY.equalTo(self.weightLabel);
        }];
        [self.waistlineUnit mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.waistlineLabel.mas_right).offset(viewPix(5));
            make.centerY.equalTo(self.waistlineLabel);
        }];
        self.layer.mask = self.cornerLayer;
    }
    return self;
}

-(void)setDateString:(NSString *)dateString{
    _dateString = dateString;
    self.dateLabel.text = dateString;
}
-(void)setWeight:(NSString *)weight{
    _weight = weight;
    self.weightLabel.text = weight;
}

-(void)setWaistline:(NSString *)waistline{
    _waistline = waistline;
    self.waistlineLabel.text = waistline;
    self.waistlineUnit.hidden = (waistline.length>0)?NO:YES;
}

-(CAShapeLayer *)cornerLayer{
    if(!_cornerLayer){
        _cornerLayer = [[CAShapeLayer alloc]init];
        _cornerLayer.frame = self.bounds;
    }
    return _cornerLayer;
}

-(UILabel *)dateLabel{
    if(!_dateLabel){
        _dateLabel = [UILabel lableWithText:@"" colorString:@"#FFFFFF" textFont:LGFontWeight(14, UIFontWeightMedium) textAlignment:NSTextAlignmentLeft lines:1];
    }
    return _dateLabel;
}

-(UILabel *)weightLabel{
    if(!_weightLabel){
        _weightLabel = [UILabel lableWithText:@"" colorString:@"#FFFFFF" textFont:LGFontWeight(14, UIFontWeightMedium) textAlignment:NSTextAlignmentLeft lines:1];
    }
    return _weightLabel;
}

-(UILabel *)weightUnit{
    if(!_weightUnit){
        _weightUnit = [UILabel lableWithText:@"kg" colorString:@"#DADADA" textFont:LGFont(12) textAlignment:NSTextAlignmentLeft lines:1];
    }
    return _weightUnit;
}

-(UILabel *)waistlineLabel{
    if(!_waistlineLabel){
        _waistlineLabel = [UILabel lableWithText:@"" colorString:@"#FFFFFF" textFont:LGFontWeight(14, UIFontWeightMedium) textAlignment:NSTextAlignmentLeft lines:1];
    }
    return _waistlineLabel;
}

-(UILabel *)waistlineUnit{
    if(!_waistlineUnit){
        _waistlineUnit = [UILabel lableWithText:@"cm" colorString:@"#DADADA" textFont:LGFont(12) textAlignment:NSTextAlignmentLeft lines:1];
    }
    return _waistlineUnit;
}


@end
